From: Joey Hess Date: Wed, 12 Feb 2025 04:37:40 +0000 (-0800) Subject: fix convertToWindowsNativeNameSpace bug X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~6^2~158^2~10^2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=6653e000f0b061772812f9735e615979555b8d55;p=git-annex.git fix convertToWindowsNativeNameSpace bug This fixes a test suite failure. The OsPath conversion made that be used in more places, including addurl, which exposed an existing bug. --- diff --git a/Utility/Path/Windows.hs b/Utility/Path/Windows.hs index 4e2da49f70..ab9c9518e0 100644 --- a/Utility/Path/Windows.hs +++ b/Utility/Path/Windows.hs @@ -14,6 +14,7 @@ module Utility.Path.Windows ( import Utility.Path import Utility.OsPath +import qualified Utility.OsString as OS import Utility.SystemDirectory import Utility.FileSystemEncoding @@ -38,9 +39,15 @@ convertToWindowsNativeNamespace f -- will not be resolved once it's converted. cwd <- getCurrentDirectory let p = simplifyPath (combine cwd (toOsPath f)) + -- If the input path is absolute but does not include a drive, + -- add the drive from the cwd, because a path in the native + -- namespace must include a drive. + let p' = if OS.null (takeDrive p) + then joinDrive (takeDrive cwd) p + else p -- Normalize slashes. - let p' = encodeBS $ WinPath.normalise $ fromOsPath p - return (win32_file_namespace <> p') + let p'' = encodeBS $ WinPath.normalise $ fromOsPath p' + return (win32_file_namespace <> p'') where win32_dev_namespace = "\\\\.\\" win32_file_namespace = "\\\\?\\"